<?php

/*
 * This file is part of the Symfony framework.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace slinks\extensions\assetic\compiler;

use slinks\core\DependencyInjection\ContainerBuilder;
use slinks\core\DependencyInjection\Compiler\CompilerPassInterface;
use slinks\core\dependencyInjectionExt\compiler\ICompilerPass;
use slinks\core\DependencyInjection\Compiler\PassConfig;

/**
 * Tags either the closure JAR or API filter for the filter manager.
 *
 * @author Kris Wallsmith <kris.wallsmith@symfony.com>
 */
class CheckClosureFilterPass implements ICompilerPass
{
    public function process(ContainerBuilder $container)
    {
        if ($container->hasDefinition('assetic.filter.closure.jar') &&
            $container->getParameterBag()->resolveValue($container->getParameter('assetic.filter.closure.jar'))) {
            $container->remove('assetic.filter.closure.api');
        } elseif ($container->hasDefinition('assetic.filter.closure.api')) {
            $container->remove('assetic.filter.closure.jar');
        }
    }
    
    public function getType() {
        return PassConfig::TYPE_BEFORE_OPTIMIZATION;
    }
}
